// components/imagesView/imagesView.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    imgArr:{
      type:Array,
      value:[]
    },
    isShow:{
      type:Boolean,
      value:false
    },
    imgIndex:{
      type:Number,
      value:0
    }

  },

  /**
   * 组件的初始数据
   */
  data: {
    index:0

  },
  created(){
    
    // this.setData({
    //   index:this.data.imgIndex
    // })
  },
  attached(){
    this.setData({
      index:this.data.imgIndex
    })
    console.log(this.data)
  },
  
  

  /**
   * 组件的方法列表
   */
  methods: {
    toNext(){
      const imgNum = this.data.imgArr.length
      const index = this.data.index
      if(index<imgNum-1){
        this.setData({
          index:index+1
        })
      }else{
        this.setData({
          index:0
        })
      }
    },

    toPre(){
      const imgNum = this.data.imgArr.length
      const index = this.data.index
      if(index>0){
        this.setData({
          index:index-1
        })
      }else{
        this.setData({
          index:imgNum-1
        })
      }
    },
    handleClose(){
      
      this.triggerEvent('handleClose')
    }

  }
})